
** Loading data - generated in dofile: data1
** Reshaping by year to have to create an empty dataset with 12 wage observations for each individual
forval t = 2012/2015{
	use "$data\minwage_data01_bef`t'_cohort1992_1999.dta", clear
	
	local s2 = (`t'-2007)*12
	local s1 = `s2'-11
	
	forval j=`s1'/`s2'{
		ge t`j' = .
	}
	
	reshape long t, i(pnr) j(month)
	drop t
	** Merging SA information on to indivduals
	merge 1:1 pnr month using "$data\minwage_data08_SA_`t'_04022019.dta", nogen keep(match master)

	** Creating a few birthday related variables
	ge brthmnth = month(foed_dag`t')
	ge yr18  = year(foed_dag`t') + 18
	ge month18 = (yr18-2008)*12+brthmnth // Basline is set to 1 in Jan2008: legacy coding
	ge tline = month - month18

	ge indkaar = `t'
	rename foed_dag`t' foed_dag

	save "$data\minwage_data09_SA_`t'.dta", replace
}

** Combining annual datasets
use "$data\minwage_data09_SA_2012.dta", clear
forval t = 2013/2015{
	append using  "$data\minwage_data09_SA_`t'.dta"
}
** Dataset includes SA observations by individuals, birth cohort 1992-1999, per month from 2012 to 2015
save "$data\minwage_data09_SA_2012_2015.dta", replace
